﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Pampa.WebControls;

namespace Pampa.CRUD.Utils
{
    public static class ControlFinder
    {
        public static Control FindParentOf(BaseControl control, string id)
        {
            if (control.Page != null)
            {
                return control.Page.FindControl(id);
            }
            else
            {
                foreach (Control sibling in control.Parent.Controls)
                {
                    if (sibling.ID == id)
                    {
                        return sibling;
                    }
                }

                return null;
            }
        }
    }
}
